<template>
    <div class="app-container">
        <el-card shadow="never">

            <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                    <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="open">添加</el-button>
                </el-col>
                <el-col :span="1.5" v-if="false">
                    <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="api.delete">删除</el-button>
                </el-col>
                <el-col :span="1.5" v-if="false">
                    <el-button type="warning" plain icon="el-icon-download" size="mini" v-loading="exportLoading" @click="handleExport" v-hasPermi="api.export">导出</el-button>
                </el-col>
                <right-toolbar :showSearch.sync="showSearch" @queryTable="initIndex" :columns="columns" printId="#quickadmin"></right-toolbar>
            </el-row>

            <!-- 列表 -->
            <qa-table
                :source="tableData"
                :columns="columns"
                :selection="false"
                :loading="loading"
                @sortChange="sortChange"
                @statusChange="statusChange"
                @selectionChange="selectionChange"
                id="quickadmin"
            >
                <template v-slot:action>
                    <el-table-column label="操作" width="180" v-if="false">
                        <template slot-scope="scope">
                            <el-button size="mini" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)" v-hasPermi="api.edit">编辑</el-button>
                            <el-button size="mini" type="text" icon="el-icon-tickets" @click="handleDetail(scope.row)" v-hasPermi="api.find">详情</el-button>
                            <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="api.delete">删除</el-button>
                        </template>
                    </el-table-column>
                </template>
            </qa-table>

            <!-- 分页 -->
            <pagination :total="total" :page.sync="pageInfo.page" :limit.sync="pageInfo.limit" @pagination="initIndex" />
        </el-card>

        <!-- 编辑弹窗 -->
       <el-dialog :title="!disabled ? '编辑' : '详情'" :visible="editOpen" :before-close="beforeClose" destroy-on-close append-to-body>
            <EditForm ref="editForm" :findFormData="findFormData"
                      :disabled="disabled"
                      :editFormParams="editFormParams"
                      :extForm="{
                          partner_id: queryObj.partner_id,
                          user_id: queryObj.user_id
                      }"
                      @submitForm="submitForm"
                      @editFormCancel="beforeClose" />
        </el-dialog>
    </div>
</template>

<script>
import { curdMixin } from '@/mixins/curdMixin'
import EditForm from './EditFormCom'
export default {
    name: 'Curd',
    mixins: [curdMixin],
    components: { EditForm },
    props: {
        queryObj: {
            type: Object,
            default: ()=> {}
        }
    },
    data() {
        return {
            // table结构
            columns: [
                {
                    visible: true,
                    label: '编号',
                    prop: 'id',
                    width: 60
                },
                {
                    visible: true,
                    label: '类型',
                    prop: 'type',
                    width: 80,
                    formatter: (prop, row) => {
                        return  row.type_text
                    },
                },
                {
                    visible: true,
                    label: '变更金额',
                    prop: 'money',
                },
                {
                    visible: true,
                    label: '变更前金额',
                    prop: 'money_after',
                },
                {
                    visible: true,
                    label: '变更后金额',
                    prop: 'money_before',
                },
                {
                    visible: true,
                    label: '创建时间',
                    prop: 'create_time',
                },
                {
                    visible: false,
                    label: '更新时间',
                    prop: 'update_time',
                },
                {
                    visible: true,
                    label: '备注',
                    prop: 'remark',
                },
            ],
            // 接口地址
            api: {
                index: `/admin/pz.partner_bond_log/index`,
                find: `/admin/pz.partner_bond_log/find`,
                add: `/admin/pz.partner_bond_log/add`,
                edit: `/admin/pz.partner_bond_log/edit`,
                delete: `/admin/pz.partner_bond_log/delete`,
                export: `/admin/pz.partner_bond_log/export`,
                status: `/admin/pz.partner_bond_log/status`
            },
            editFormParams: {},
            // 搜索表单是否展开
            searchExpand: false,
            // 查询参数
            queryParams: {},
            type:[
               { label: "收入", value: 1 },
               { label: "支出", value: 2 },
            ],
        }
    },
    methods: {
    }
}
</script>
